var express = require('express');
var router = express.Router();

let { getSalespersons, updateSalespersons, deleteSalespersons, getCustomerList, addSalespersons, getCustomerList1, getPersonOne } = require('../service/salespersonsService');
//获取销售员信息
router.get('/getSalespersons', async function (req, res, next) {
    let data = await getSalespersons();
    res.send(data);
});
//新增销售员账号
router.post('/addSalespersons', async function (req, res, next) {
    console.log(req.body);
    let data = await addSalespersons(req.body);
    res.send(data);
});

//修改销售员信息
router.post('/updateSalespersons', async function (req, res, next) {
    let data = await updateSalespersons(req.body);
    res.send(data);
});

//删除销售员
router.post('/deleteSalespersons', async function (req, res, next) {
    let data = await deleteSalespersons(req.body);
    res.send(data);
});

//查看该销售员负责的客户列表
router.get('/getCustomerList', async function (req, res, next) {
    let data = await getCustomerList();
    res.send(data);
});
//查看该销售员负责的客户列表List
router.post('/getCustomerList1', async function (req, res, next) {
    let data = await getCustomerList1(req.body);
    res.send(data);
});

//获取某一个销售员的信息
router.get('/getPersonOne', async function (req, res) {
    let data = await getPersonOne(req.query)
    res.send(data)
})

module.exports = router;
